package com.team.employment.web.admin.controller.communal;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.team.employment.common.result.Result;
import com.team.employment.model.enums.ReleaseStatus;
import com.team.employment.web.admin.custom.audit.StatusAuditStrategyFactory;
import com.team.employment.web.admin.dto.ReleaseStatusSubmitDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "发布状态管理")
@RestController
@RequestMapping("/admin/isRelease")
public class IsReleaseController<T> {

    @Autowired
    private StatusAuditStrategyFactory factory;

    @Operation(summary = "单个修改发布状态")
    @PutMapping("updateOne")
    public Result updateOne( @RequestParam String entityType,@RequestParam Long id,@RequestParam ReleaseStatus releaseStatus) {
        IService<T> service = factory.getService(entityType);
        UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",id).set("isRelease",releaseStatus);
        service.update(updateWrapper);
        return Result.ok();
    }

    @Operation(summary = "批量修改发布状态")
    @PutMapping("updateMore")
    public Result updateMore( @RequestParam String entityType,@RequestBody ReleaseStatusSubmitDto releaseStatusSubmitDto) {
        IService<T> service = factory.getService(entityType);
        return Result.ok();
    }
}
